package com.cms.controller;

import java.io.File;
import java.util.Map;

import com.cms.common.JsonResult;
import com.cms.service.table.TableService;
import com.cms.service.table.TableServiceImpl;
import com.jfinal.core.Controller;
import com.jfinal.kit.PathKit;

public class TableController extends Controller {
	
	TableService tableService = new TableServiceImpl();
	
	public void index() {
		renderJsp("/pages/table/table_list.jsp");
	}

	
	/** 
     * table的分页展示
     */  
    public void  pagination() {
    	int pageNumber = getParaToInt("pageNumber");
		int pageSize = getParaToInt("pageSize");
		String search = getPara("search");
		String name = getPara("name");
		Map<String, Object> returnMap = tableService.getTableALL(pageNumber, pageSize,search,name);
		renderJson(returnMap);
    } 
    
    public void createTable() {
    	 JsonResult result = new JsonResult();
    	  String tableLists = getPara("tableLists");
    	  tableService.createTable(tableLists);
    	  renderJson(result.status("000").show("createTable"));

    }
    public void getCode() {
    	 String webRootPath = PathKit.getWebRootPath();
    	  renderFile(new File(webRootPath+"/java/"+"code.zip"));
    }
    
    
    
	
}
